package com.erbao.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author CaoBaoYin
 * @since 22/4/22 16:01
 */
public class TestDataTypeSize {


    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        PreparedStatement ps = connection.prepareStatement("insert into psn1(id, name) values (?, ?)");
        System.out.println("开发准备数据……");
        for (int i = 0; i < 20_000; i++) {
            ps.setInt(1, i);
            ps.setString(2, i+"name");
            ps.addBatch();
        }
        System.out.println("开始执行存储数据……");
        ps.executeBatch();
        System.out.println("开始关闭资源……");
        ps.close();
        connection.close();
    }

}
